package graphics.view;

import graphics.Animatable;
import graphics.Canvas;

import java.awt.BorderLayout;

import javax.swing.JPanel;

public class Framed extends javax.swing.JFrame implements java.util.Observer {
	private Canvas myDisplay;

	public Framed(java.awt.Dimension size, String game) {
		myDisplay = new Canvas(size);
		initGui(myDisplay);
	}

	private void initGui(Canvas display) {
		setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
		JPanel panel = new JPanel(new BorderLayout());
		panel.add(myDisplay, BorderLayout.CENTER);
		getContentPane().add(panel);
		setFocusable(true);
		requestFocus();
		pack();
		setVisible(true);
	}

	public void update(java.util.Observable engine, Object model) {
		myDisplay.setModel((Animatable) model);
		myDisplay.repaint();
	}
}